package com.kangyi.admin.mapper;

import com.github.pagehelper.Page;
import com.kangyi.admin.annotation.AutoFill;
import com.kangyi.dto.ReviewPageDTO;
import com.kangyi.dto.ReviewPageQueryDTO;
import com.kangyi.entity.NursingHomeReview;
import com.kangyi.entity.NursingHomeReviewReply;
import com.kangyi.enumeration.OperationType;
import com.kangyi.vo.ReviewDetailVO;
import com.kangyi.vo.ReviewPageQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface ReviewMapper {

    Page<ReviewPageQueryVO> pageQuery(ReviewPageDTO reviewPageDTO);

    @Insert("insert into nursing_home_review_reply (review_id, admin_user_id, content, create_time, update_time, create_user, update_user) " +
            "values (#{reviewId},#{adminUserId},#{content},#{createTime},#{updateTime},#{createUser},#{updateUser});")
    @AutoFill(value = OperationType.INSERT)
    void replyReview(NursingHomeReviewReply nursingHomeReviewReply);

    ReviewDetailVO detailReview(Integer reviewId);

    @Select("select * from nursing_home_review where user_id = #{userId};")
    List<NursingHomeReview> getByUserId(Integer userId);

    @Delete("delete from nursing_home_review where user_id = #{userId};")
    void deleteByUserId(Integer userId);

    @Select("select * from nursing_home_review where nursing_home_id = #{nursingHomeId};")
    List<NursingHomeReview> getByNursingHomeId(Integer nursingHomeId);

    @Delete("delete from nursing_home_review where nursing_home_id = #{nursingHomeId};")
    void deleteByNursingHomeId(Integer nursingHomeId);
}
